package game.ouroboros.magic;

import framework.Input.TouchEvent;
import framework.maths.CollisionTester;
import framework.maths.Rectangle;
import android.content.Context;

public class Menu {

	private static final String TAG = "MenuClass";

	private TrapManager map;

	private Context context;

	private int trapWidht;
	private int trapHeight;

	public Menu(TrapManager map, Context context) {
		this.map = map;
		this.context = context;
		createCollisionRects(32, 32, 22, 9 );
	}

	private void createCollisionRects(int trapW, int trapH, int positionX,
			int positionY) {
		int offsetX = 0;
		int offsetY = 0;
		positions = new Rectangle[13];
		for (int i = 0; i < 12; i++, offsetX += trapW) {
			if (i == 6) {
				offsetY = 32;
				offsetX = 0;
			}
			positions[i] = new Rectangle(positionX + offsetX, positionY
					+ offsetY, trapW, trapH);
		}
		positions[12] = new Rectangle(221, positionY, 200, 80);
	}

	private Rectangle[] positions;

 
	public int touchMenu(TouchEvent event) {
		for (int i = 0; i < 12; i++) {
			if (CollisionTester
					.pointInRectangle(positions[i], event.x, event.y)) {
				return i;
			}
		}
		if(CollisionTester.pointInRectangle(positions[12], event.x, event.y)){
			return 666;
		}
		return -1;
	}
}
